package eu.flexblog.core.view
{
	import eu.flexblog.core.ApplicationFacade;
	import eu.flexblog.core.view.components.ContentShell;
	
	import flash.display.DisplayObject;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;
	
	/**
	 * ContentShell mediator
	 * @author Mike Bevz <myb@flexblog.eu>
	 * 
	 */	
	public class ContentShellMediator extends Mediator
	{
		public static const NAME:String = 'ContentShellMediator';
		
		public function ContentShellMediator(viewComponent:ContentShell):void 
		{
			super(NAME, viewComponent);
		}
		
		override public function listNotificationInterests():Array
		{
			return [ ApplicationFacade.ADD_WIDGET, 
					 ApplicationFacade.REMOVE_WIDGET,
					 ApplicationFacade.ADD_MODULE
			       ];
		}
		
		
		override public function handleNotification(note:INotification):void
		{
			switch ( note.getName() )
			{
				case ApplicationFacade.ADD_MODULE:
					contentShell.addChild(note.getBody() as DisplayObject);
					break;
					
				case ApplicationFacade.ADD_WIDGET:
					//contentShell.addChild(note.getBody() as DisplayObject);
					break;
					
				case ApplicationFacade.REMOVE_WIDGET:
					contentShell.removeChild(note.getBody() as DisplayObject);
					break;
			}
		}
		
		
		/**
		 * Return ContentShell instance
		 * @return ContentShell 
		 * 
		 */		
		public function get contentShell():ContentShell
		{
			return viewComponent as ContentShell;
		}
		
	}
}